<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div class="box">
    <h1>{{title}}</h1>
    <p>{{content}}</p>
  </div>

  <script type="text/javascript">
    var oBox = document.getElementsByClassName('box')[0]
    var tpl = oBox.innerHTML
    var res = tpl.replace(/{{(.*?)}}/g, function (node, key) {
      // console.log(node, key);
      return {
        title: 'tpl test',
        content: 'i am a bbb'
      } [key]
    })
    oBox.innerHTML = res
  </script>
</body>

</html>